package edu.ihs.lhpy.base;

import java.lang.reflect.ParameterizedType;

import javax.annotation.Resource;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

import edu.ihs.lhpy.service.*;

public class BaseAction<T> extends ActionSupport implements ModelDriven<T>{

	@Resource
	protected TeacherService teacherService;
	@Resource
	protected InstituteService instituteService;
	@Resource
	protected UserService userService;
	@Resource
	protected PrivilegeService privilegeService;
	@Resource
	protected NewsService newsService;
	@Resource
	protected WorkGuideService workGuideService;
	@Resource
	protected StudentsGuideService studentsGuideService;
	@Resource
	protected BaseInfoService baseInfoService;
	
	protected T model ;
	public BaseAction(){
		
		try {
			//得到model T类型的真实信息
			ParameterizedType pt = (ParameterizedType) this.getClass().getGenericSuperclass();
			Class clazz = (Class) pt.getActualTypeArguments()[0];
			//目标是生成model的实例，，通过反射机制
			model = (T) clazz.newInstance();
		} catch (Exception e) {
			e.printStackTrace();
		} 
	}
	@Override
	public T getModel() {
		return model;
	}
	//传递的pageNum默认为第一页
	protected int pageNum = 1;
	public int getPageNum() {
		return pageNum;
	}
	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}
}
